﻿using System.ComponentModel;

namespace GlobalizationTools.ViewModel
{
    public class ResourceData : INotifyPropertyChanged
    {
        object _value = null;
        TabControlItemViewModel _parent;
        private bool _isModified = true;

        public ResourceData(TabControlItemViewModel parent)
        {
            _parent = parent;
        }

        public ResourceData(TabControlItemViewModel parent, object value)
            :this(parent)
        {
            _value = value;
            _isModified = false;
        }

        public object Value
        {
            get { return _value; }
            set
            {
                if (_value != value)
                {
                    _value = value;
                    _isModified = true;
                    OnPropertyChanged("Value");
                    _parent.IsModified = true;
                }
            }
        }

        public bool IsModified
        {
            get { return _isModified; }
            set { _isModified = value; }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion INotifyPropertyChanged Members

    }
}
